﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace TLSharp
{
    public class BrowseLadderResponse
    {
        public string MessageType = "";
        public int LadderListLength =0;
        public List<string> Ladder;
        public int ErrorCode;
        public string UserMessage;

        private List<Team> _LadderObjects = null;

        public List<Team> LadderObjects
        {
            get
            {
                if (_LadderObjects == null && (Ladder != null && Ladder.Count > 0))
                {
                    _LadderObjects = new List<Team>();
                    foreach (string ThisString in Ladder)
                    {
                        Newtonsoft.Json.Linq.JObject o = JObject.Parse(ThisString);

                        Team b = (Team)(new JsonSerializer()).Deserialize(new JsonTokenReader(o), typeof(Team));

                        JValue ThisValue = new JValue(ThisString);
                        _LadderObjects.Add(b);
                    }
                }
                return _LadderObjects;
            }
        }
    }
}
